using NewFormatProject.Infrastructure.EFCore;
using NewFormatProject.Infrastructure.Dto.Responses.Objects;
using NewFormatProject.Repository.Instances;
using System.Linq;
namespace NewFormatProject.Server.Instances.Extends.Entitys
{
    public static class SysRightsExtend
    {
        public static ResponseSysRightsDto ToResponseDto(this SysRights entity)
        {
            return new ResponseSysRightsDto
            {
                id = entity.RId,
                name = entity.RName,
                url = entity.RUrl,
                isBan = entity.RIsBan,
                parentId = entity.RParentId,
                parentName = new Repository<SysRights>(new Core2Context()).Query(d => d.RId == entity.RParentId).Select(d => d.RName).SingleOrDefault(),
                hasMenu = entity.RHasMenu,
                createTime = entity.RCreateTime,
            };
        }
    }
}
